package tech.aistar.corejava.day05.day05work;

/**
 * Created by 豆梦寒 on 2019/7/21.
 */
public class Person {
    private String name;//姓名
    private boolean gender;//性别
    private int age;//年龄
    private String partner="";//是否结婚

    public Person() {
    }

    public Person(String name, boolean gender, int age, String partner) {
        this.name = name;
        this.gender=gender;
        this.age = age;
        this.partner = partner;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Person{");
        sb.append("name='").append(name).append('\'');
        sb.append(", gender=").append(gender);
        sb.append(", age=").append(age);
        sb.append(", partner='").append(partner).append('\'');
        sb.append('}');
        return sb.toString();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean getGender() {
        return gender;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getPartner() {
        return partner;
    }

    public void setPartner(String partner) {
        this.partner = partner;
    }


//    public boolean marry(Person person) {
//        if (this.gender != person.gender && "".equals(this.partner)
//                && "".equals(person.partner)) {
//            if ((this.age >= 24 && person.age >= 22)
//                    || (this.age >= 22 && person.age >= 24)) {
//                this.partner = person.name;
//                person.partner = this.name;
//                System.out.println(this.name + " 和 " + person.name
//                        + " 可以结婚!");
//                return true;
//            }
//        }
//        return false;
//    }
public boolean marry(Person person) {
    if (this.gender != person.gender && "".equals(this.partner)
            && "".equals(person.partner)) {
        if ((this.gender && this.age >= 24 && person.age >= 22)
                || (!this.gender && this.age >= 22 && person.age >= 24)) {
            this.partner = person.name;
            person.partner = this.name;
            System.out.println(this.name + " 和 " + person.name
                    + " 可以结婚");
            return true;
        } else {
            System.out.println(this.name + " 和 " + person.name
                    + " ,不可以结婚...");
        }
    } else {
        System.out.println(this.name + " 和 " + person.name
                + " 你俩太小...");
    }
    return false;
}
}
